package cn.findviewbydream.evil.bigtoutiao.fragment;

import android.app.Fragment;
import android.support.v13.app.FragmentPagerAdapter;
import android.support.v4.view.PagerTabStrip;
import android.support.v4.view.ViewPager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import cn.findviewbydream.evil.bigtoutiao.R;
import cn.findviewbydream.evil.bigtoutiao.base.BaseFragment;

/********************************************
 * 工程名：BigTouTiao
 * 包名：cn.findviewbydream.evil.bigtoutiao.fragment
 * 时间：17-7-1
 * 作者：白雨濃 evil
 * 邮箱：evilbai@foxmail.com
 * 内容：
 ********************************************/
public class MicroFragment extends BaseFragment
{
    private static MicroFragment fragment;

    @BindView(R.id.pager_tab)
    PagerTabStrip pagerTab;
    @BindView(R.id.viewPager)
    ViewPager viewPager;

    public static MicroFragment getInstance()
    {
        if (fragment == null)
            fragment = new MicroFragment();
        return fragment;
    }

    @Override
    public int setFragmentViewId()
    {
        return R.layout.fragment_micro;
    }

    @Override
    public void setFragmentCreateView()
    {
        initView();
    }

    @Override
    protected void initView()
    {
        initViewPager();
    }

    private void initViewPager()
    {
        List<String> titleList = new ArrayList<>();
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");
        titleList.add("最新推荐");
        titleList.add("游戏娱乐");
        titleList.add("影音视频");


        List<Fragment> fragmentList = new ArrayList<>();// 将要分页显示的View装入数组中

        /*fragmentList.add(VideoFragment.getInstance());
        fragmentList.add(VideoFragment.getInstance());
        fragmentList.add(VideoFragment.getInstance());*/


        FragmentPagerAdapter adapter = new FragmentPagerAdapter(getActivity().getFragmentManager())
        {
            @Override
            public Fragment getItem(int position)
            {
                return VideoFragment.getInstance();
            }

            @Override
            public int getCount()
            {
                return titleList.size();
            }

            @Override
            public CharSequence getPageTitle(int position)
            {
                return titleList.get(position);
            }
        };

        viewPager.setAdapter(adapter);
    }
}
